/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.animation
{
	public class AnimationPlayer
	{
		private var animationItems:Vector.<AnimationItem>;
		
		public function AnimationPlayer()
		{
			animationItems = new Vector.<AnimationItem>();
		}
		
		public function play(item:AnimationItem):void{
			animationItems.push(item);
		}
		
		public function draw():void{
			if(animationItems.length){
				var leftItems:Vector.<AnimationItem> = new Vector.<AnimationItem>();
				while(animationItems.length){
					var item:AnimationItem = animationItems.shift();
					if(item.draw()){
						leftItems.push(item);
					}else{
						item.complete();
					}
					
				}
				animationItems = leftItems;
			}
		}		
	}
}